SRC           = $(shell find . -name '*.[cS]')
OBJ           = $(SRC:%=%.o)

CC            = arm-elf-gcc
CFLAGS        = -Wall -fno-builtin -I../../lib/
LD            = arm-elf-ld
LDFLAGS	      = -L../../lib 
LSCRIPT       = link_sdram.ld
IMAGE         = giraffe
DEPENDFILE    = depend

all:	$(BOOTIMAGE)

.PHONY: clean dep

clean:
	rm -f *.o *~
	rm -f $(IMAGE) $(IMAGE).bin $(BOOTIMAGE)

%.c.o: %.c
	$(CC) $(CFLAGS) -o $@ -c $<


%.S.o: %.S 
	$(CC) $(CFLAGS) -o $@ -c $<

dep: $(SRC)
	$(CC) -MM $(SRC) > $(DEPENDFILE)

-include $(DEPENDFILE)

$(IMAGE): $(OBJ)
	$(LD) $(LDFLAGS) -T$(LSCRIPT) -o $@ $^ -lA
	mk_exe $(IMAGE) giraffe.esel
	




